﻿XIncludeFile "Function.pb"

;==============================函数类型===============================

;==================================常数==================================
Enumeration
 #Style=1
 #Visible=2
 #Enabled=4
EndEnumeration

;==============================窗口结构==============================
Structure GdipImage Extends PWnd
  Style.l
  DrawStyle.l
EndStructure

;================================函数===========================================

Procedure IImageText(*Image.GdipImage,Text.s)
 With *Image
   GdipDisposeImage(\Creat\ImageBack)
   If \DrawStyle
      GdipCreateBitmapFromScan0(\Width,\Height,0,#GDIPLUS_PIXELFORMAT_32bppARGB, 0,@\Creat\ImageBack)
      GdipGetImageGraphicsContext(\Creat\ImageBack,@Graphics)
      GdipSetCompositingMode(Graphics,#CompositingModeSourceCopy)
      If \DrawStyle=1
        GdipDrawImageRectI(Graphics,\Image,0,0,\Width,\Height)
      Else 
        GdipDrawImageRectI(Graphics,\Image,0,0,GdipImageWidth(\Image),GdipImageHeight(\Image))
      EndIf 
      GdipDeleteGraphics(Graphics)
   Else
      GdipCloneImage(\Image,@\Creat\ImageBack)
      GdipGetImageWidth(\Image,@\Width )
      GdipGetImageHeight(\Image,@\Height)
   EndIf 
 EndWith
EndProcedure

Procedure IImageSize(*Image.GdipImage,Width,Height)
  *Image\wText(*Image,"")
EndProcedure

Procedure IImageLoad(*Image.GdipImage)
  *Image\wText(*Image,"")
EndProcedure

Procedure IImageDraw(*Image.GdipImage,*Gadget.PWnd,*cRect.RECT)

EndProcedure

Procedure IImageEvent(*Image.GdipImage,hWnd, uMsg, wParam, lParam)
  If *Image\Enabled =3
    ProcedureReturn  1
  EndIf 
  ProcedureReturn  1
EndProcedure

Procedure IImageIsLoca(*Image.GdipImage,hWnd,X,Y)
  X-*Image\X
  Y-*Image\Y
  If X>-1 And Y>-1 And X<*Image\Width And Y<*Image\Height  And *Image\Visible
     GdipBitmapGetPixel(*Image\Creat\ImageBack,X,Y,@Color)
     If GdipAlpha(Color)
        ProcedureReturn *Button
     EndIf 
  EndIf 
EndProcedure

Procedure IImageFree(*Image.GdipImage)
  DeleteWindowList(*Image)
EndProcedure

Procedure GdipCreateImageG(*Hwnd.PWnd,X,Y,Width,Height,Image,Style=6,DrawStyle=0)  ;创建文本输入框
 *Image.GdipImage=AddWindowList(@*Hwnd\Gadget,SizeOf(GdipImage))
 GdipCloneImage(Image,@*Image\Image)
 With *Image
    \X=X
    \Y=Y
    \Width=Width
    \Height=Height
    \Visible=IsVal(Style,#Visible)
    \Enabled=(1-IsVal(Style,#Enabled))*3
    \Type=#Label
    \Style=IsVal(Style,1)
    \DrawStyle=DrawStyle
    \HostGadget=*Hwnd
    *Hwnd\NewGadget= *Image
    \wIsLoca=@IImageIsLoca()
    \wLoad=@IImageLoad()
    \wDraw=@IImageDraw()
    \wEvent=@IImageEvent()
    \wFree=@IImageFree()
    \wSize=@IImageSize()
    \wText=@IImageText()   
  EndWith
  ProcedureReturn  *Image
EndProcedure


; IDE Options = PureBasic 4.30 (Windows - x86)
; CursorPosition = 86
; FirstLine = 8
; Folding = T50
; EnableAsm
; EnableUnicode
; EnableXP
; HideErrorLog